#include<iostream>
#include<vector>
#include<stack>
using namespace std;

const int N=1000;
bool cmz[N];
int main()
{
	string s;cin>>s;
	stack<int> st;//存下标
	for(size_t  i=0;i<s.size();i++)
	{
		char ch=s[i];
		if(ch=='('||ch=='[') st.push(i);
		else if(ch==')'||ch==']')
		{
			if(st.empty()) continue;
			int t=st.top();
			char left=s[t];
			if(left=='('&&ch==')')
			{
				cmz[i]=cmz[t]=true;
				st.pop();
			}
			if(left=='['&&ch==']')
			{
				cmz[i]=cmz[t]=true;
				st.pop();
			}
		}
	}
	string ret;
	for(size_t i=0;i<s.size();i++)
	{
		char ch=s[i];
		if(cmz[i]) ret+=ch;
		else
		{

            if(ch == '(')
            {
                ret += ch;
                ret += ')';
            }
            else if(ch == ')')
            {
                ret += '(';
                ret += ch;
            }
            else if(ch == '[')
            {
                ret += ch;
                ret += ']';
            }
            else
            {
                ret += '[';
                ret += ch;
            }
		}
	}
	cout<<ret<<endl;
	return 0;
}